<script>
	export default {
		onLaunch: function() {
			// 定位获取经纬度
			uni.getLocation({
				success: ({longitude,latitude}) => {
					let url = `https://restapi.amap.com/v3/geocode/regeo?key=3cdf846aab977e514073cb7297e94f47&location=${longitude},${latitude}`
					//请求高德地图服务接口，获取位置信息
					uni.request({
						url,
						success: (res) => {
							console.log(res);
							let {city,province} = res.data.regeocode.addressComponent
							let cityName = city.length?city:province
							let lnglat = [longitude,latitude]
							this.$store.commit('loc/initCity',{cityName,lnglat})
						}
					})
				}
			})
			
			// 尝试提取本地存储用户信息
			try {
				const value = uni.getStorageSync('uni-2206-userInfo');
				if (value) {
					console.log('本地存储用户信息',value);
					this.$store.commit('user/initInfoMut',value)
				}
			} catch (e) {
				// error
				console.log('用户信息提取失败');
			}

		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
		
	}
</script>

<style lang="scss">
	/*每个页面公共css */
	@import url('./colorui/main.css');
	@import url('./colorui/icon.css');
	@import './tuniao-ui/index.scss';
    @import './tuniao-ui/iconfont.css';
	@import './static/font/iconfont.css';  
</style>
